// see http://vuejs-templates.github.io/webpack for documentation.

//index.js 中有 dev 和 production 两种环境的配置
var path = require('path') // 使用NodeJS 自带的文件路径插件

module.exports = {
  build: {  // production (生产) 环境
    env: require('./prod.env'), // 使用 config/prod.env.js 中定义的编译环境
    index: path.resolve(__dirname, '../dist/index.html'), // 编译输入的index.html文件
    assetsRoot: path.resolve(__dirname, '../dist'), // 编译输出的静态资源路径
    assetsSubDirectory: 'static',//编译输出的二级目录
    assetsPublicPath: '/',//编译发布的根目录，可配置为资源服务器域名 或者 CDN域名
    productionSourceMap: true,  //是否开启 cssSourceMap
    // Gzip off by default as many popular static hosts such as
    // Surge or Netlify already gzip all static assets for you.
    // Before setting to `true`, make sure to:
    // npm install --save-dev compression-webpack-plugin
    productionGzip: false,  //是否开启 gzip
    productionGzipExtensions: ['js', 'css'],  //需要使用 gzip 压缩的文件拓展名
    // Run the build command with an extra argument to
    // View the bundle analyzer report after build finishes:
    // `npm run build --report`
    // Set to `true` or `false` to always turn it on or off
    bundleAnalyzerReport: process.env.npm_config_report
  },
  dev: { //dev 环境
    env: require('./dev.env'),  //使用 config/dev.env.js 中定义的编译环境
    port: 8000,    //运行测试页面的端口
    autoOpenBrowser: true,   // 是否自动打开浏览器
    assetsSubDirectory: 'static',  //编译输出二级目录
    assetsPublicPath: '/', //编译发布的根目录， 可配置为资源服务器域名 或 cdn 域名
    //需要 proxyTable 代理的接口（可跨域）
    proxyTable: {
      //proxy all requests starting with /api to jsonplaceholder
      '/api': {
        target: 'http://192.168.10.124:8080',
        changeOrigin: true,
        pathRewrite: {
          '^/api': ''
        }
      }
    },
    // CSS Sourcemaps off by default because relative paths are "buggy"
    // with this option, according to the CSS-Loader README
    // (https://github.com/webpack/css-loader#sourcemaps)
    // In our experience, they generally work as expected,
    // just be aware of this issue when enabling this option.
    cssSourceMap: false  //是否开启 cssSourceMap （因为一些bug 此项默认关闭，详情可参考  https://github.com/webpack/css-loader#sourcemaps）
  }
}
